/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConsultarReserva.java
 *
 * Created on 23/06/2010, 09:12:53 PM
 */

package CapaGrafica;
import javax.swing.JOptionPane;
import CapaLogica.ComunicacionServidor;

/**
 *
 * @author Maria
 */
public class ConsultaReserva extends javax.swing.JFrame {

   private MenuUsuario ventanaMadre;
    /** Creates new form ConsultarReserva */
    public ConsultaReserva(MenuUsuario ventana) {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBcontinuar = new javax.swing.JButton();
        jBcancelar = new javax.swing.JButton();
        jLingreseId = new javax.swing.JLabel();
        jTFidReserva = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setLocationByPlatform(true);

        jBcontinuar.setText("continuar");
        jBcontinuar.setName("jBcontinuar"); // NOI18N
        jBcontinuar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBcontinuarActionPerformed(evt);
            }
        });

        jBcancelar.setText("Cancelar");
        jBcancelar.setName("jBcancelar"); // NOI18N

        jLingreseId.setText("Ingrese el id de la reserva");
        jLingreseId.setName("jLingreseId"); // NOI18N

        jTFidReserva.setName("jTFidReserva"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLingreseId)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                        .addComponent(jTFidReserva, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jBcontinuar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 117, Short.MAX_VALUE)
                        .addComponent(jBcancelar)))
                .addGap(75, 75, 75))
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLingreseId)
                    .addComponent(jTFidReserva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(91, 91, 91)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBcontinuar)
                    .addComponent(jBcancelar))
                .addGap(52, 52, 52))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBcontinuarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBcontinuarActionPerformed
      String ID = jTFidReserva.getText();
        String mensajeError = "No se encontró ninguna reservacion con el ID <b>" + ID + "</b> asociada a su cuenta";
        String mensaje = ComunicacionServidor.consultarReservacion (ventanaMadre.getCedulaCliente(), jTFidReserva.getText());
        String[] infoReserva = mensaje.split (":");

        if (infoReserva[0].equals(ID))
        {
            InformacionReserva ventana = new InformacionReserva (infoReserva);
            ventana.setVisible (true);
        }
        else
            JOptionPane.showMessageDialog (this, mensajeError);  // TODO add your handling code here:
    }//GEN-LAST:event_jBcontinuarActionPerformed

    /**
    * @param args the command line arguments
    */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBcancelar;
    private javax.swing.JButton jBcontinuar;
    private javax.swing.JLabel jLingreseId;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTFidReserva;
    // End of variables declaration//GEN-END:variables

}
